/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package vn.com.fis.portal.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import vn.com.fis.portal.model.NotificationEntry;
import vn.com.fis.portal.model.NotificationEntryModel;
import vn.com.fis.portal.model.NotificationEntrySoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the NotificationEntry service. Represents a row in the &quot;TBL_NOTIFICATION&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link vn.com.fis.portal.model.NotificationEntryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link NotificationEntryImpl}.
 * </p>
 *
 * @author loind
 * @see NotificationEntryImpl
 * @see vn.com.fis.portal.model.NotificationEntry
 * @see vn.com.fis.portal.model.NotificationEntryModel
 * @generated
 */
@JSON(strict = true)
public class NotificationEntryModelImpl extends BaseModelImpl<NotificationEntry>
	implements NotificationEntryModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a notification entry model instance should use the {@link vn.com.fis.portal.model.NotificationEntry} interface instead.
	 */
	public static final String TABLE_NAME = "TBL_NOTIFICATION";
	public static final Object[][] TABLE_COLUMNS = {
			{ "notificationId", Types.BIGINT },
			{ "userIdFrom", Types.BIGINT },
			{ "userIdTo", Types.BIGINT },
			{ "subject", Types.VARCHAR },
			{ "message", Types.VARCHAR },
			{ "createDate", Types.TIMESTAMP },
			{ "status", Types.INTEGER }
		};
	public static final String TABLE_SQL_CREATE = "create table TBL_NOTIFICATION (notificationId LONG not null primary key,userIdFrom LONG,userIdTo LONG,subject VARCHAR(75) null,message VARCHAR(75) null,createDate DATE null,status INTEGER)";
	public static final String TABLE_SQL_DROP = "drop table TBL_NOTIFICATION";
	public static final String ORDER_BY_JPQL = " ORDER BY notificationEntry.createDate ASC";
	public static final String ORDER_BY_SQL = " ORDER BY TBL_NOTIFICATION.createDate ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.vn.com.fis.portal.model.NotificationEntry"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.vn.com.fis.portal.model.NotificationEntry"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.vn.com.fis.portal.model.NotificationEntry"),
			true);
	public static long USERIDFROM_COLUMN_BITMASK = 1L;
	public static long USERIDTO_COLUMN_BITMASK = 2L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static NotificationEntry toModel(NotificationEntrySoap soapModel) {
		NotificationEntry model = new NotificationEntryImpl();

		model.setNotificationId(soapModel.getNotificationId());
		model.setUserIdFrom(soapModel.getUserIdFrom());
		model.setUserIdTo(soapModel.getUserIdTo());
		model.setSubject(soapModel.getSubject());
		model.setMessage(soapModel.getMessage());
		model.setCreateDate(soapModel.getCreateDate());
		model.setStatus(soapModel.getStatus());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<NotificationEntry> toModels(
		NotificationEntrySoap[] soapModels) {
		List<NotificationEntry> models = new ArrayList<NotificationEntry>(soapModels.length);

		for (NotificationEntrySoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.vn.com.fis.portal.model.NotificationEntry"));

	public NotificationEntryModelImpl() {
	}

	public long getPrimaryKey() {
		return _notificationId;
	}

	public void setPrimaryKey(long primaryKey) {
		setNotificationId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_notificationId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return NotificationEntry.class;
	}

	public String getModelClassName() {
		return NotificationEntry.class.getName();
	}

	@JSON
	public long getNotificationId() {
		return _notificationId;
	}

	public void setNotificationId(long notificationId) {
		_notificationId = notificationId;
	}

	@JSON
	public long getUserIdFrom() {
		return _userIdFrom;
	}

	public void setUserIdFrom(long userIdFrom) {
		_columnBitmask |= USERIDFROM_COLUMN_BITMASK;

		if (!_setOriginalUserIdFrom) {
			_setOriginalUserIdFrom = true;

			_originalUserIdFrom = _userIdFrom;
		}

		_userIdFrom = userIdFrom;
	}

	public long getOriginalUserIdFrom() {
		return _originalUserIdFrom;
	}

	@JSON
	public long getUserIdTo() {
		return _userIdTo;
	}

	public void setUserIdTo(long userIdTo) {
		_columnBitmask |= USERIDTO_COLUMN_BITMASK;

		if (!_setOriginalUserIdTo) {
			_setOriginalUserIdTo = true;

			_originalUserIdTo = _userIdTo;
		}

		_userIdTo = userIdTo;
	}

	public long getOriginalUserIdTo() {
		return _originalUserIdTo;
	}

	@JSON
	public String getSubject() {
		if (_subject == null) {
			return StringPool.BLANK;
		}
		else {
			return _subject;
		}
	}

	public void setSubject(String subject) {
		_subject = subject;
	}

	@JSON
	public String getMessage() {
		if (_message == null) {
			return StringPool.BLANK;
		}
		else {
			return _message;
		}
	}

	public void setMessage(String message) {
		_message = message;
	}

	@JSON
	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_columnBitmask = -1L;

		_createDate = createDate;
	}

	@JSON
	public int getStatus() {
		return _status;
	}

	public void setStatus(int status) {
		_status = status;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public NotificationEntry toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (NotificationEntry)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					NotificationEntry.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		NotificationEntryImpl notificationEntryImpl = new NotificationEntryImpl();

		notificationEntryImpl.setNotificationId(getNotificationId());
		notificationEntryImpl.setUserIdFrom(getUserIdFrom());
		notificationEntryImpl.setUserIdTo(getUserIdTo());
		notificationEntryImpl.setSubject(getSubject());
		notificationEntryImpl.setMessage(getMessage());
		notificationEntryImpl.setCreateDate(getCreateDate());
		notificationEntryImpl.setStatus(getStatus());

		notificationEntryImpl.resetOriginalValues();

		return notificationEntryImpl;
	}

	public int compareTo(NotificationEntry notificationEntry) {
		int value = 0;

		value = DateUtil.compareTo(getCreateDate(),
				notificationEntry.getCreateDate());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		NotificationEntry notificationEntry = null;

		try {
			notificationEntry = (NotificationEntry)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = notificationEntry.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		NotificationEntryModelImpl notificationEntryModelImpl = this;

		notificationEntryModelImpl._originalUserIdFrom = notificationEntryModelImpl._userIdFrom;

		notificationEntryModelImpl._setOriginalUserIdFrom = false;

		notificationEntryModelImpl._originalUserIdTo = notificationEntryModelImpl._userIdTo;

		notificationEntryModelImpl._setOriginalUserIdTo = false;

		notificationEntryModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<NotificationEntry> toCacheModel() {
		NotificationEntryCacheModel notificationEntryCacheModel = new NotificationEntryCacheModel();

		notificationEntryCacheModel.notificationId = getNotificationId();

		notificationEntryCacheModel.userIdFrom = getUserIdFrom();

		notificationEntryCacheModel.userIdTo = getUserIdTo();

		notificationEntryCacheModel.subject = getSubject();

		String subject = notificationEntryCacheModel.subject;

		if ((subject != null) && (subject.length() == 0)) {
			notificationEntryCacheModel.subject = null;
		}

		notificationEntryCacheModel.message = getMessage();

		String message = notificationEntryCacheModel.message;

		if ((message != null) && (message.length() == 0)) {
			notificationEntryCacheModel.message = null;
		}

		Date createDate = getCreateDate();

		if (createDate != null) {
			notificationEntryCacheModel.createDate = createDate.getTime();
		}
		else {
			notificationEntryCacheModel.createDate = Long.MIN_VALUE;
		}

		notificationEntryCacheModel.status = getStatus();

		return notificationEntryCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(15);

		sb.append("{notificationId=");
		sb.append(getNotificationId());
		sb.append(", userIdFrom=");
		sb.append(getUserIdFrom());
		sb.append(", userIdTo=");
		sb.append(getUserIdTo());
		sb.append(", subject=");
		sb.append(getSubject());
		sb.append(", message=");
		sb.append(getMessage());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", status=");
		sb.append(getStatus());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(25);

		sb.append("<model><model-name>");
		sb.append("vn.com.fis.portal.model.NotificationEntry");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>notificationId</column-name><column-value><![CDATA[");
		sb.append(getNotificationId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userIdFrom</column-name><column-value><![CDATA[");
		sb.append(getUserIdFrom());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userIdTo</column-name><column-value><![CDATA[");
		sb.append(getUserIdTo());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>subject</column-name><column-value><![CDATA[");
		sb.append(getSubject());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>message</column-name><column-value><![CDATA[");
		sb.append(getMessage());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>status</column-name><column-value><![CDATA[");
		sb.append(getStatus());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = NotificationEntry.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			NotificationEntry.class
		};
	private long _notificationId;
	private long _userIdFrom;
	private long _originalUserIdFrom;
	private boolean _setOriginalUserIdFrom;
	private long _userIdTo;
	private long _originalUserIdTo;
	private boolean _setOriginalUserIdTo;
	private String _subject;
	private String _message;
	private Date _createDate;
	private int _status;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private NotificationEntry _escapedModelProxy;
}